package org.example.panel.userpanel;
import javax.swing.*;
import java.awt.event.*;
import org.example.frame.*;
import org.example.model.*;
import org.example.operation.*;

/**
 * @author lenovo
 */

public class DeleteUserPanel extends JPanel{
    public DeleteUserPanel(User user,JFrame frame){
        //组件准备
        JButton deleteUser = new JButton("注销用户");
        //注册监视器
        deleteUser.addActionListener((ActionEvent e)->{
            UserOperation.deleteUser(user.getUsername());
            JOptionPane.showMessageDialog(null,
                    "注销用户成功", null , JOptionPane.WARNING_MESSAGE);
            new FirstFrame();
            frame.dispose();
        });
        //添加组件
        add(deleteUser);
    }
}
